home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / AEpropagateMenuCB.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.5 KB  |  145 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  27 Nov 1997
  22. //  Author:         ajp
  23. //
  24. //  Description:
  25. //      This procedure controls the behaviour of
  26. //        the navigator buttons that appear at the
  27. //        top of the attribute editor
  28. //
  29. //  Input Arguments:
  30. //        $type = whether we're looking for forward or
  31. //                backward connections
  32. //        $menu = the popup menu control name
  33. //                ("" if the button is hit with the LMB)
  34. //        $node = the name of the node
  35. //        
  36. //  Return Value:
  37. //      None
  38. //
  39.  
  40.  
  41. global proc AEpropagateMenuCB(string $type, string $menu, string $node)
  42. {
  43.  
  44.     if ( $menu != "" ) {
  45.         setParent -m $menu;
  46.         popupMenu -e -deleteAllItems $menu;
  47.     }
  48.  
  49.     // get a list of all the plugs in the desired direction
  50.     //
  51.     string $allPlugs[];
  52.     string $plugs[];
  53.     if ( $type == "-backward" ) {
  54.         // note: since we need to do an extra filtering step for
  55.         // backward connections, we use a temporary string array ($allPlugs)
  56.         //
  57.         $allPlugs = `listConnections -s false -d true -c true -p true $node`;
  58.     } else if ( $type == "-forward" ) {
  59.         $plugs = `listConnections -s true -d false -c true -p true $node`;
  60.     }
  61.  
  62.     // loop through the plugs and filter out those that are connected
  63.     // to invalid attributes (only for backward connections)
  64.     //
  65.     int $i;
  66.     if ( size($plugs) == 0 && size($allPlugs) > 0 ) {
  67.  
  68.         // get a list of attributes that we'll check for connections;
  69.         // these attributes must be:
  70.         //    visible
  71.         //    connectable
  72.         //    readOnly
  73.         //
  74.         string $attrs[] = `listAttr -visible -connectable -readOnly $node`;
  75.  
  76.         for ( $i = 0; $i < size($allPlugs); $i += 2 ) {
  77.  
  78.             // tokenize the indexed $allPlugs such that:
  79.             //    currentNodeBuffer[0] is the nodeName
  80.             //    currentNodeBuffer[1] is the attributeName
  81.             //    currentNodeBuffer[2] would be the multi index if defined
  82.             //
  83.             string $currentNodeBuffer[];
  84.             tokenize($allPlugs[$i], ".[]", $currentNodeBuffer);
  85.  
  86.             // search for the attribute name in the attribute list;
  87.             // if we find it, add it to our list of valid plugs: $plugs
  88.             //
  89.             for ( $j = 0; $j < size($attrs); $j++ ) {
  90.                 if ( $currentNodeBuffer[1] == $attrs[$j] ) {
  91.                     // got a valid one
  92.                     $plugs[size($plugs)] = $allPlugs[$i];
  93.                     $plugs[size($plugs)] = $allPlugs[$i+1];
  94.                     break; // from $j loop
  95.                 }
  96.             }
  97.  
  98.             // if we don't want a whole menu (i.e. just
  99.             // do a showEditor on the first item in the
  100.             // list) we can break from this loop if we've
  101.             // got at least one plug
  102.             //
  103.             if ( $menu == ""  && size($plugs) > 0 ) {
  104.                 break; // from $i loop
  105.             }
  106.         }
  107.     }
  108.  
  109.     // now we have a list of valid plugs;
  110.     // depending on what we want to do with this list,
  111.     // we can now either build a pop-up menu, or
  112.     // simply show the first item in the list
  113.     // in the attribute editor
  114.     //
  115.     string $currentNodeBuffer[], $connectedNodeBuffer[];
  116.     if ( $menu == "" ) {
  117.         // show the attribute editor for the first connection
  118.         //
  119.         if ( size($plugs) > 0 ) {
  120.             tokenize($plugs[1], ".", $connectedNodeBuffer);
  121.             showEditorExact $connectedNodeBuffer[0];
  122.         }
  123.     } else {
  124.         // build the menuItems for the popup
  125.         //
  126.         for ( $i = 0; $i < size($plugs); $i += 2 ) {
  127.             tokenize($plugs[$i], ".", $currentNodeBuffer);
  128.             tokenize($plugs[$i+1], ".", $connectedNodeBuffer);
  129.             string $command = ("showEditorExact "+$connectedNodeBuffer[0]);
  130.             string $label = "";
  131.             switch ( $type ) {
  132.               case "-backward":
  133.                 $label = ($currentNodeBuffer[1]+" -> "+$plugs[$i+1]);
  134.                 break;
  135.               case "-forward":
  136.                 $label = ($plugs[$i+1]+" -> "+$currentNodeBuffer[1]);
  137.                 break;
  138.               default:
  139.                 break;
  140.             }
  141.             menuItem -l $label -c $command;
  142.         }
  143.     }
  144. }
  145.